import { Module } from '@nestjs/common'
import { JwtModule } from '@nestjs/jwt'
import { APP_GUARD } from '@nestjs/core'

import { AuthService } from './auth.service'
import { AuthController } from './auth.controller'
import { MenuModule } from './menu/menu.module'
import { RoleModule } from './role/role.module'
import { OperationModule } from './operation/operation.module'
import { UserModule } from 'src/user/user.module'
import { AuthGuard } from './auth.guard'
import { LoggerModule } from 'src/logger/logger.module'

import { JWT_SECRET_KEY } from 'config'
import { RoleService } from './role/role.service'

@Module({
  imports: [
    LoggerModule,
    MenuModule,
    RoleModule,
    OperationModule,
    UserModule,
    JwtModule.register({
      secret: process.env.JWT_SECRET || JWT_SECRET_KEY,
      signOptions: {}
    })
  ],
  controllers: [AuthController],
  providers: [
    AuthService,
    {
      provide: APP_GUARD,
      useClass: AuthGuard
    }
  ]
})
export class AuthModule {}
